<?php

    #-------------------------------------------------------------#
	# This file is part of the Tekuna MVC Microframework for PHP. #
	# (c) 2009 Niels Jäckel <niels.jaeckel@tekuna.org>            #
	# Please visit http://tekuna.org/ for more information.       #
	#                                                             #
	# This software is licensed under the MIT License. Please     #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#


	Tekuna :: load('org.tekuna.core.application.DefaultLayoutComposer');


	class LayoutComposerTest extends AbstractTekunaTestCase {

		public function testLayoutComposer() {

			// build application module
			$objModule = new ApplicationModule();

			// build layout composer instance
			$objLC = new DefaultLayoutcomposer();
			$objLC -> setModule($objModule);

			// test valid output
			$arrSlots = array('slot1' => 'aaa',
			                  'slot2' => '123',
			                  'slots' => array('slot3' => 'foo'));

			$sExpectedOutput = "aaa\n123\nfoo";

			$objModule -> setLayout('ThreeSlotLayout.tpl');
			$this -> assertIdentical($objLC -> composeLayout($arrSlots), $sExpectedOutput);

			// test invalid template
			$objModule -> setLayout('nonExistentLayout.tpl');

			try {

				$objLC -> composeLayout(array());
				$this -> fail();
			}
			catch (TemplateNotFoundException $e) {

				$this -> pass();
			}
		}
	}



